﻿using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using QuickUIT.Controls;

namespace QuickUIT.Tests
{
    [TestClass]
    public class UIStatusBarTests
    {
        private BaseState _baseState;

        [TestInitialize]
        public void TestSetup()
        {
            _baseState = new BaseState(TestUtilities.GetTestApplicationFileName(), "@Name='QuickUIT Test Application'");
            _baseState.Execute();
        }

        [TestMethod]
        public void ShouldGetStatusBar()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var statusBar = window.UIStatusBar("@AutomationId='statusBar1'");
            Assert.IsNotNull(statusBar);
        }

        [TestMethod]
        public void ShouldGetAllStatusBars()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            List<UIStatusBar> statusBars = window.UIStatusBars();
            Assert.AreEqual(1, statusBars.Count);
            Assert.AreEqual("statusBar1", statusBars[0].AutomationId);
        }

        [TestMethod]
        public void ShouldGetDefaultRowCountForUnsupportedStatusBar()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var statusBar = window.UIStatusBar("@AutomationId='statusBar1'");
            Assert.AreEqual(-1, statusBar.RowCount);
        }

        [TestMethod]
        public void ShouldGetDefaultColumnCountForUnsupportedStatusBar()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var statusBar = window.UIStatusBar("@AutomationId='statusBar1'");
            Assert.AreEqual(-1, statusBar.ColumnCount);
        }

        [TestMethod]
        [ExpectedException(typeof(InvalidOperationException))]
        public void ShouldThrowExceptionOnGetItemForUnsupportedScollBar()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            var statusBar = window.UIStatusBar("@AutomationId='statusBar1'");
            statusBar.GetItem(0, 0); 
        }

        [TestCleanup]
        public void TestTeardown()
        {
            _baseState.Cleanup();
        }
    }
}